package com.yonyou.pmclouds.safeinspection.process;

import com.yonyou.pmclouds.basecom.billstatus.BillStatusConst;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.safeinspection.entity.SafeInspectionVO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author 徐老板
 * @date 2020/4/21   15:33
 */
public class InsertchecknullBeforeProcess implements SingleProcessor<SafeInspectionVO> {



    @Override
    public void process(SafeInspectionVO vo, SafeInspectionVO orig) throws BusinessException {
        if (vo==null){
            throw new BusinessException("现场安全检查记录不能为空");
        }else
        if (StringUtils.isEmpty(vo.getCheckArea())){
            throw new BusinessException("检查部位不能为空");
        }else
        if (StringUtils.isEmpty(vo.getPk_process())){
            throw new BusinessException("工序不能为空");
        }else
        if (StringUtils.isEmpty(vo.getPk_safeinspection())){
            throw new BusinessException("安全标准不能为空");
        }

        //设置单据状态忘记添加
        vo.setBill_type(BillTypeConst.SAFEINSPECTION_BILLTYPE);
        //设计单据审批状态
        vo.setBillstatus(BillStatusConst.COMMON_FREE_STATUS);
    }
}
